import http from '@/utils/http'

// 查询部门列表
export function queryTree (params) {
  return http({
    url: '/system/dept/queryTree',
    method: 'post',
    data: http.adornData(params)
  })
}

// 查询部门树列表（排除节点）
export function listDeptExcludeChild (deptId) {
  return http({
    url: '/system/dept/listTreeExcludeChild/10/0/' + deptId,
    method: 'get'
  })
}

// 查询部门详细
export function getDept (deptId) {
  return http({
    url: '/system/dept/info/' + deptId,
    method: 'get'
  })
}

// 根据角色ID查询部门树结构
export function roleDeptTree (roleId) {
  return http({
    url: '/system/dept/roleDeptTree/' + roleId,
    method: 'get'
  })
}

// 新增部门
export function addDept (data) {
  return http({
    url: '/system/dept/save',
    method: 'post',
    data: http.adornData(data)
  })
}

// 修改部门
export function updateDept (data) {
  return http({
    url: '/system/dept/update',
    method: 'post',
    data: http.adornData(data)
  })
}

// 删除部门
export function delDept (deptIds) {
  return http({
    url: '/system/dept/delete/' + deptIds,
    method: 'post'
  })
}

// 查询部门下拉树结构
export function getCurrentUsedOrderNum (parentId) {
  return http({
    url: '/system/dept/getCurrentUsedOrderNum/' + parentId,
    method: 'get'
  })
}

// 按部门分组人员树
export function userSelectTree (deptId, expandLevel) {
	if (deptId == null || deptId === '') {
		deptId = '0'
	}
  if (expandLevel == null || expandLevel === '') {
    expandLevel = '1'
  }
  return http({
    url: '/system/dept/userSelectList/' + expandLevel + '/' + deptId,
    method: 'get'
  })
}

// 查询部门详细
export function getDeptInfoByIds (userIds) {
  return http({
    url: '/system/dept/listByIds',
    method: 'post',
    data: http.adornData(userIds, false)
  })
}
